import random
import re
import time


def Tu_xin_yan_zheng_ma(num):
    s = ''
    for i in range(num):
        up = random.randint(ord('A'), ord('Z'))
        lw = random.randint(ord('a'), ord('z'))
        digital = random.randint(ord('0'), ord('9'))
        s += random.choice([chr(up), chr(lw), chr(digital)])
    return s


def shuZiYanZhengMa(num):
    a = []
    for i in range(num):
        a.append(random.randint(0, 9))
    return a


def random_char(upper=True):
    if upper:
        t = random.randint(ord('A'), ord('Z'))
        return chr(t)
    else:
        t = random.randint(ord('a'), ord('z'))
        return chr(t)


def rand_string(length):
    s = ''
    for i in range(length):
        s += random_char(random.choice([True, False]))
    return s


def YanZhengMa(length):
    return rand_string(length)


def is_id_number(s):
    result = re.match(r'^\d{6}((20[012]\d)|(1[89]\d\d))\d{7}(\d|X)$', s)
    return result


def is_phone_number(s):
    result = re.match(r'^1\d{10}$', '15948294720')
    return result


def get_time():
    t = time.localtime()
    t = time.strftime('%Y-%m-%d %H:%M:%S', t)
    return t
